package checker

import (
	"kumachan/interpreter/lang/ast"
	"kumachan/interpreter/lang/common/source"
	"kumachan/interpreter/compiler/checker/typsys"
	"kumachan/interpreter/compiler/checker/checked"
)


func (cc *checkContext) checkChild(expected typsys.Type, checker ExprChecker) (*checked.Expr, *source.Error) {
	var expr, s, err = checker(expected, cc.inferring, cc.exprContext)
	if err != nil { return nil, err }
	cc.inferring = s
	return expr, nil
}
func (cc *checkContext) checkChildExpr(expected typsys.Type, node ast.Expr) (*checked.Expr, *source.Error) {
	return cc.checkChild(expected, check(node))
}
func (cc *checkContext) checkChildTerm(expected typsys.Type, node ast.VariousTerm) (*checked.Expr, *source.Error) {
	return cc.checkChildExpr(expected, ast.WrapTermAsExpr(node))
}


